﻿using CommandLine;
using CommandLine.Text;

namespace DbTeleportáció
{
    /// <summary>
    /// Used by the command line argument parser to define command line switched that can be passed
    /// when invoking this application
    /// </summary>
    /// <remarks>
    /// -------------------------------------------Change Log---------------------------------------------
    /// 04/01/2016 - DCS - Created
    /// --------------------------------------------------------------------------------------------------
    /// </remarks>
    public class Options
    {
        [Option('c', "Delimeter", HelpText = "Character to use to delimit data.", DefaultValue = ",", Required = false)]
        public string Delimeter { get; set; }

        [Option('d', "Database", HelpText = "Database from which to retrieve data.", Required = true)]
        public string Database { get; set; }

        [Option('e', "FileExtension", HelpText = "Extension appended to data export files.", Required = false, DefaultValue = ".txt")]
        public string FileExtension { get; set; }

        [Option('f', "FileDropDirectory", HelpText = "Directory in which to drop the exported data files", Required = true)]
        public string FileDropDirectory { get; set; }

        [Option('i', "IgnoreColumns", HelpText = "Delimited list of tables[columns] to ignore during the export.  Wildcards not supported.  Example: Table1[column2,column3,column4]|Table2[column5] would exclude column2, column3, and column4 from Table1 and column5 from Table2.", Required = false)]
        public string IgnoreColumns { get; set; }

        [Option('p', "Password", HelpText = "Password used to connect to the database.", Required = false)]
        public string Password { get; set; }

        [Option('s', "Server", HelpText = "Database server to connect to", Required = true)]
        public string Server { get; set; }

        [Option('t', "TextQualifier", HelpText = "Character that is used to wrap text contents to prevent instances of the delimeter from breaking the export.", Required = false, DefaultValue = "\"")]
        public string TextQualifier { get; set; }

        [Option('u', "Username", HelpText = "Username used to connect to the database", Required = false)]
        public string Username { get; set; }

        [Option('v', "Verbose", HelpText = "Verbose output written to the console for debugging.", DefaultValue = false, Required = false)]
        public bool Verbose { get; set; }

        [Option('w', "WaitToExit", HelpText = "Specifies that the application should wait for the user to press a key before exiting.", DefaultValue = false, Required = false)]
        public bool WaitToExit { get; set; }

        [Option('x', "ExcludedTables", HelpText = "Pipe-delimited list of tables to exclude or ignore.  EndsWith wildcards supported.  Example: Table1|Table2|sys* (this would exclude tables named Table1, Table2, and any table starting with 'sys').", Required = false)]
        public string ExcludedTables { get; set; }

        [Option("SkipCompression", HelpText = "Does not compress the output so additional (manual) processing can be performed", Required = false, DefaultValue = false)]
        public bool SkipCompression { get; set; }

        [HelpOption('h')]
        public string GetUsage()
        {
            return HelpText.AutoBuild(this, (HelpText current) => HelpText.DefaultParsingErrorsHandler(this, current));
        }
    }
}